@model DiscountPartViewModel

@{
    var discount = Model.Discount;
    var discountPercentageValue = discount.DiscountPercentage;
    var maximumProducts = discount.MaximumProducts;
    var minimumProducts = discount.MinimumProducts;
}

@if(Model.NewPrice.Amount is { IsValid: true } newPrice)
{
    <div class="pb-3 field field-type-pricefield field-name-discount-part-new-price">
        <strong class="field-name-discount-part-new-title-title">@T["New Price with Discount after Taxes:"]</strong>
        @newPrice
    </div>
}

@if (discountPercentageValue > 0)
{
    <div class="field field-type-numericfield field-name-discount-part-discount-percentage">
        <strong class="field-name-discount-part-discount-percentage-title">@T["Discount Percentage:"]</strong>
        @T["{0}%", discountPercentageValue]
    </div>
}

@if (maximumProducts > 0 && maximumProducts >= minimumProducts )
{
    <div class="field field-type-numericfield field-name-discount-part-maximum-products">
        <strong class="field-name-discount-part-maximum-products-title">@T["Discount Maximum Products:"]</strong>
        @maximumProducts
    </div>
}

@if (minimumProducts > 1)
{
    <div class="field field-type-numericfield field-name-discount-part-minimum-products">
        <strong class="field-name-discount-part-minimum-products-title">@T["Discount Minimum Products:"]</strong>
        @minimumProducts
    </div>
}

@if (discount.BeginningUtc is { } beginningUtc)
{
    <div class="field field-type-datetimefield field-name-discount-part-beginning">
        <strong class="field-name-discount-part-beginning-title">@T["Discount Beginning:"]</strong>
        @await DisplayAsync(await New.DateTime(Utc: beginningUtc, Format: "g"))
    </div>
}

@if (discount.ExpirationUtc is { } expirationUtc)
{
    <div class="field field-type-datetimefield field-name-discount-part-expiration">
        <strong class="field-name-discount-part-expiration-title">@T["Discount Expiration:"]</strong>
        @await DisplayAsync(await New.DateTime(Utc: expirationUtc, Format: "g"))
    </div>
}

